<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>Class: ActiveBackground::Client</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />

    <script language="JavaScript" type="text/javascript">
    // <![CDATA[

        function toggleSource( id )
        {
          var elem
          var link

          if( document.getElementById )
          {
            elem = document.getElementById( id )
            link = document.getElementById( "l_" + id )
          }
          else if ( document.all )
          {
            elem = eval( "document.all." + id )
            link = eval( "document.all.l_" + id )
          }
          else
            return false;

          if( elem.style.display == "block" )
          {
            elem.style.display = "none"
            link.innerHTML = "show source"
          }
          else
          {
            elem.style.display = "block"
            link.innerHTML = "hide source"
          }
        }

        function openCode( url )
        {
          window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
        }
      // ]]>
    </script>

  </head>

  <body>
  <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
  <td class="file-title"><span class="file-title-prefix">Class</span><br />ActiveBackground::Client</td>
  <td align="right">
    <table cellspacing=0 cellpadding=2>
      <tr valign="top">
        <td>In:</td>
        <td>

<a href="../../files/vendor/plugins/active_background/tasks/__/lib/active_background/client_rb.html">vendor/plugins/active_background/tasks/../lib/active_background/client.rb</a>
        </td>
      </tr>
    <tr>
      <td>Parent:</td>
      <td>
        <a href="Base.html">
Base
         </a>

     </td>
   </tr>
         </table>
        </td>
        </tr>
      </table>
 <!-- banner header -->

  <div id="bodyContent">
      <div id="content">




  <div class="sectiontitle">Methods</div>
  <ul>
  <li><a href="#M000053">connect</a></li>
  <li><a href="#M000056">method_missing</a></li>
  <li><a href="#M000051">new</a></li>
  <li><a href="#M000052">prepare</a></li>
  <li><a href="#M000055">terminate_server</a></li>
  <li><a href="#M000054">wait_for_server</a></li>
  </ul>


<div class="sectiontitle">Included Modules</div>
<ul>
  <li>Singleton</li>
</ul>






<div class="sectiontitle">Public Class methods</div>
<div class="method">
  <div class="title">
    <a name="M000051"></a><b>new</b>()
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000051_source')" id="l_M000051_source">show source</a> ]</p>

  <div id="M000051_source" class="dyn-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/active_background/tasks/../lib/active_background/client.rb, line 7</span>
7:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
8:     <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>

<div class="sectiontitle">Public Instance methods</div>
<div class="method">
  <div class="title">
    <a name="M000053"></a><b>connect</b>(client_options = {:server =&gt; :master})
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000053_source')" id="l_M000053_source">show source</a> ]</p>

  <div id="M000053_source" class="dyn-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_background/tasks/../lib/active_background/client.rb, line 31</span>
31:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">connect</span>(<span class="ruby-identifier">client_options</span> = {<span class="ruby-identifier">:server</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:master</span>})
32:       <span class="ruby-ivar">@client_options</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">client_options</span>
33:       <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Client: Client options are #{@client_options.inspect}&quot;</span>)
34:       <span class="ruby-identifier">server_options</span> = {<span class="ruby-identifier">:host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">server</span>(<span class="ruby-identifier">client_options</span>[<span class="ruby-identifier">:server</span>]).<span class="ruby-identifier">host</span>, <span class="ruby-identifier">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">server</span>(<span class="ruby-identifier">client_options</span>[<span class="ruby-identifier">:server</span>]).<span class="ruby-identifier">port</span>}
35:       <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Client: Server options are #{server_options.inspect}&quot;</span>)
36:       
37:       <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@client_options</span>[<span class="ruby-identifier">:local</span>]
38:         <span class="ruby-identifier">uri</span> = <span class="ruby-node">&quot;druby://#{server_options[:host]}:#{server_options[:port]}&quot;</span>
39:         <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-value str">&quot;Client: Connecting to remote&quot;</span>)
40:         <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Client: Server URI #{uri}&quot;</span>)
41:         <span class="ruby-constant">DRb</span>.<span class="ruby-identifier">start_service</span>()
42:         <span class="ruby-ivar">@@server</span> = <span class="ruby-constant">DRbObject</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">uri</span>)
43:       <span class="ruby-keyword kw">else</span>
44:         <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-value str">&quot;Client: Connecting to local&quot;</span>)
45:         <span class="ruby-ivar">@@server</span> = <span class="ruby-constant">ActiveBackground</span><span class="ruby-operator">::</span><span class="ruby-constant">Manager</span>.<span class="ruby-identifier">instance</span>
46:       <span class="ruby-keyword kw">end</span>
47:     <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000052"></a><b>prepare</b>()
  </div>
  <div class="description">

  <p>
this method is called before every method
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000052_source')" id="l_M000052_source">show source</a> ]</p>

  <div id="M000052_source" class="dyn-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_background/tasks/../lib/active_background/client.rb, line 11</span>
11:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">prepare</span>
12:       <span class="ruby-keyword kw">begin</span>
13:         <span class="ruby-identifier">connect</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@@server</span>
14:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@@server</span>.<span class="ruby-identifier">terminated?</span>
15:           <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">error</span>(<span class="ruby-value str">&quot;Client: Server is being terminated&quot;</span>)
16:           <span class="ruby-comment cmt"># TODO: Redirect new jobs to cache</span>
17:         <span class="ruby-keyword kw">end</span>
18:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
19:           <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">error</span>(<span class="ruby-value str">&quot;\n******************************************\n&quot;</span> <span class="ruby-operator">+</span>
20:                         <span class="ruby-node">&quot;Exception: #{e.to_s} - (#{e.class})\n&quot;</span> <span class="ruby-operator">+</span>
21:                         <span class="ruby-value str">&quot;Client: Cannot connect to server, please check your configuration\n&quot;</span> <span class="ruby-operator">+</span>
22:                         <span class="ruby-value str">&quot;----------------BACKTRACE-----------------\n&quot;</span> <span class="ruby-operator">+</span>
23:                                   <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;\n&quot;</span> <span class="ruby-operator">+</span>
24:                         <span class="ruby-value str">&quot;-------------------END--------------------\n&quot;</span> <span class="ruby-operator">+</span>
25:                         <span class="ruby-value str">&quot;\n******************************************\n&quot;</span> )
26:           <span class="ruby-comment cmt"># TODO: Redirect new jobs to cache</span>
27:           <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Client: Cannot connect to server, please check your configuration&quot;</span>
28:       <span class="ruby-keyword kw">end</span>
29:     <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000055"></a><b>terminate_server</b>()
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000055_source')" id="l_M000055_source">show source</a> ]</p>

  <div id="M000055_source" class="dyn-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_background/tasks/../lib/active_background/client.rb, line 54</span>
54:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">terminate_server</span>
55:       <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-value str">&quot;Client: Terminating servers (and slave servers)&quot;</span>)
56:       <span class="ruby-ivar">@@server</span>.<span class="ruby-identifier">terminate</span>()
57:     <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000054"></a><b>wait_for_server</b>()
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000054_source')" id="l_M000054_source">show source</a> ]</p>

  <div id="M000054_source" class="dyn-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_background/tasks/../lib/active_background/client.rb, line 49</span>
49:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wait_for_server</span>()
50:       <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-value str">&quot;Client: waiting till server is completed with processing jobs&quot;</span>)
51:       <span class="ruby-ivar">@@server</span>.<span class="ruby-identifier">wait</span>()
52:     <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>

<div class="sectiontitle">Private Instance methods</div>
<div class="method">
  <div class="title">
    <a name="M000056"></a><b>method_missing</b>(method, *args, &amp;block)
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000056_source')" id="l_M000056_source">show source</a> ]</p>

  <div id="M000056_source" class="dyn-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_background/tasks/../lib/active_background/client.rb, line 60</span>
60:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">method</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
61:         <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:prepare</span>)
62:         <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
63:       <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
</div>

  </div>

    </body>
</html>